package cn.edu.jxau.test;

import java.util.LinkedList;

public class Main {

	public static boolean isPalindrome(ListNode list) {

		LinkedList<Integer> stack = new LinkedList<>();
		ListNode cur = list;
		while (cur != null) {
			stack.push(cur.val);
			cur = cur.next;
		}
		cur = list;
		while (!stack.isEmpty()) {
			if (cur.val != stack.pop()) {
				return false;
			}
			cur = cur.next;
		}
		return true;
	}
}

class ListNode {
	public int val;
	public ListNode next;

	ListNode(int val) {
		this.val = val;
	}

	public ListNode append(int val) {

		ListNode node = new ListNode(val);
		node.next = this.next;
		this.next = node;
		return node;
	}
}
